home *** CD-ROM | disk | FTP | other *** search
- // Filename: DOCTEMP.WMC
- // "DOCTEMP" Generated by Visual Programmer.
- // Author: Blue Sky
-
- //
- // ***********************************************************************
- // Do not add code here. Add code in the .CPP file.
- //
- // This file is maintained by the Switch-It Module.
- // As you make changes in your applications design,
- // this file is automatically updated, therefore you never modify this file.
- //
- //
- //
- // For more information,
- // see the section "How code is generated" in the documentation.
- //
- // ***********************************************************************
- //
-
- // *************************************************************
- // GLOBAL VARIABLES
- // *************************************************************
-
- BOOL bHelpSupport = FALSE; // Controlling Help Support
- DWORD dwDialogProp = 0; // Controlling Dialog Box Color
- BOOL b256Color = TRUE; // Controlling bitmap drawing
- BOOL bPreCreateCheck= TRUE; // Controlling PreCreateWindow handling
- HINSTANCE hBMPInst = 0; // Handle to instance for bitmaps
- UINT wPrivateMessage= RegisterWindowMessage("BLDPrivateMessage");
-
-
-
-
-
- // *************************************************************
- // Member Functions for Class: Cwm_BaseApplication
- // Base Class : CWinApp
- // *************************************************************
-
-
- BEGIN_MESSAGE_MAP(Cwm_BaseApplication, CWinApp)
-
- // Processing of linked menu items in menu: SIMPLE
-
- ON_COMMAND(IDM_NewWindow, wmIDM_NewWindowCM)
- ON_COMMAND(IDM_Cascade, wmIDM_CascadeCM)
- ON_COMMAND(IDM_Tile, wmIDM_TileCM)
- ON_COMMAND(IDM_ArrangeIcons, wmIDM_ArrangeIconsCM)
- ON_COMMAND(IDM_CloseActive, wmIDM_CloseActiveCM)
- END_MESSAGE_MAP()
-
-
- Cwm_BaseApplication::Cwm_BaseApplication (const char* pName)
- : CWinApp (pName)
- {
- pWndClient = NULL;
- }
-
-
- BOOL Cwm_BaseApplication::InitApplication()
- {
-
- return CWinApp::InitApplication();
- }
-
-
-
- BOOL Cwm_BaseApplication::InitInstance()
- {
- OFSTRUCT of;
- int len;
- char *pStr;
-
- if(dwDialogProp&BLDGRAY_DIALOGBOX)
- SetDialogBkColor();
-
- // Create the main window
- Cwm_MainWnd* ms_pMainUserWnd;
- ms_pMainUserWnd = BLDMainCreateWnd(NULL);
- m_pMainWnd = ms_pMainUserWnd;
-
-
- ::GetModuleFileName(AfxGetInstanceHandle(),ms_szHelpFilePath,sizeof(ms_szHelpFilePath));
- len=lstrlen(ms_szHelpFilePath);
- for (pStr=&ms_szHelpFilePath[len-1];pStr>ms_szHelpFilePath;--pStr)
- {
- if (*pStr=='\\')
- {
- pStr++;
- lstrcpy(pStr,"DOCTEMP.HLP");
- if (!::OpenFile(ms_szHelpFilePath,&of,OF_EXIST)!=-1)
- {
- lstrcpy(ms_szHelpFilePath,"DOCTEMP.HLP");
- }
- break;
- }
- }
- m_pszHelpFilePath = ms_szHelpFilePath;
-
-
- return CWinApp::InitInstance();
- }
-
-
-
- int Cwm_BaseApplication::ExitInstance()
- {
-
- return CWinApp::ExitInstance();
- }
-
-
-
- //No help support, return FALSE
- BOOL Cwm_BaseApplication::MenuHelp(DWORD dwData)
- {
- return FALSE;
- }
-
-
-
- // *************************************************************
- // Member Functions for Class: Cwm_MainBaseWnd
- // Base Class : CMDIFrameWnd
- // *************************************************************
-
-
- CString Cwm_MainBaseWnd::ms_strWndClass; //Window Class Name
-
-
- IMPLEMENT_DYNCREATE(Cwm_MainBaseWnd, CMDIFrameWnd)
-
- BEGIN_MESSAGE_MAP(Cwm_MainBaseWnd, CMDIFrameWnd)
-
- ON_REGISTERED_MESSAGE(wPrivateMessage,SimHandlePrivateMessage)
-
- END_MESSAGE_MAP()
-
-
-
- Cwm_MainBaseWnd::Cwm_MainBaseWnd()
- : CMDIFrameWnd()
- {
-
- ms_pToolbarTop= ms_pToolbarBottom=ms_pToolbarLeft=ms_pToolbarRight=NULL;
- ms_pWndClient = NULL;
-
-
- if (ms_strWndClass.IsEmpty())
- SimRegisterClass();
-
- }
-
-
-
- Cwm_MainBaseWnd::~Cwm_MainBaseWnd()
- {
- }
-
-
-
- BOOL Cwm_MainBaseWnd::SimRegisterClass()
- {
- WNDCLASS WndClass;
-
- WndClass.lpszClassName = "BLD_Main";
- WndClass.style = CS_DBLCLKS;
- WndClass.cbClsExtra = 0;
- WndClass.cbWndExtra = 0;
- WndClass.hInstance = AfxGetInstanceHandle();
- WndClass.hIcon = LoadIcon(AfxGetResourceHandle(),"MDIEDIT");
- WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
- WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- WndClass.lpszMenuName = "SIMPLE";
-
- if (!ms_strWndClass.IsEmpty())
- return TRUE; // Already registered
-
- ms_strWndClass = AfxRegisterWndClass(WndClass.style,
- WndClass.hCursor, WndClass.hbrBackground, WndClass.hIcon);
-
- if (ms_strWndClass.IsEmpty())
- return FALSE;
- else
- return TRUE;
- }
-
-
-
- BOOL Cwm_MainBaseWnd::SimInitWindow(CWnd *pAParent)
- {
- CREATESTRUCT sCr;
-
- if (ms_strWndClass.IsEmpty())
- return FALSE;
-
- sCr.lpCreateParams = NULL;
- sCr.hInstance = AfxGetInstanceHandle();
- sCr.dwExStyle = 0;
- sCr.lpszClass = ms_strWndClass;
- sCr.lpszName = "MDI Framework 1";
- sCr.style = WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_OVERLAPPED;
- sCr.hwndParent = pAParent ? pAParent->GetSafeHwnd() : (HWND)NULL;
- sCr.x = CW_USEDEFAULT;
- sCr.y = 0;
- sCr.cx = CW_USEDEFAULT;
- sCr.cy = 0;
- sCr.hMenu = NULL;
- ms_hSubMenu = 0;
- ms_hSetWindowMenuPopup = 0;
-
-
- BOOL bRet;
-
- if (sCr.cx==CW_USEDEFAULT)
- {
- bRet = Create(ms_strWndClass,sCr.lpszName,sCr.style,
- rectDefault,pAParent,
- MAKEINTRESOURCE(IDR_SIMPLE),sCr.dwExStyle);
- }
- else
- {
- RECT r;
-
- r.left = sCr.x;
- r.top = sCr.y;
- r.right = sCr.cx+sCr.x;
- r.bottom = sCr.cy+sCr.y;
-
- bRet = Create(ms_strWndClass,sCr.lpszName,sCr.style,
- r,pAParent,MAKEINTRESOURCE(IDR_SIMPLE),
- sCr.dwExStyle);
- }
-
- if (!bRet)
- {
- BLDDisplayMessage(::GetActiveWindow(),BLD_CannotCreateWindow,"Main",
- MB_OK | MB_ICONASTERISK);
- return FALSE;
- }
-
- BLDLoadAccelerators(this,IDR_SIMPLE);
-
-
- // To initialize bitmaps in menus and MDI window menu
- BLDLoadMenu(this,IDR_SIMPLE,&ms_hSubMenu,FALSE);
- ShowWindow(TheApp.m_nCmdShow);
- UpdateWindow();
-
- return TRUE;
- }
-
-
- // PreCreateWindow - overridden for window to get correct properties
- BOOL Cwm_MainBaseWnd::PreCreateWindow(CREATESTRUCT& sCr)
- {
- if (!sCr.lpszClass&&bPreCreateCheck)
- {
- HMENU hSubMenu;
-
- sCr.dwExStyle = 0;
- sCr.lpszClass = ms_strWndClass;
- sCr.lpszName = "MDI Framework 1";
- sCr.style = WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_OVERLAPPED;
-
- ms_hSubMenu = 0;
- ms_hSetWindowMenuPopup = 0;
-
- if (sCr.hMenu&&::IsMenu(sCr.hMenu))
- ::DestroyMenu(sCr.hMenu);
- sCr.hMenu = BLDLoadMenu(NULL,IDR_SIMPLE,&hSubMenu,TRUE);
- }
- return CMDIFrameWnd::PreCreateWindow(sCr);
- }
-
-
-
- void Cwm_MainBaseWnd::Cwm_SetWindowMenuPopup(HMENU hMenu)
- {
- ms_hSetWindowMenuPopup=hMenu;
- }
-
-
-
- //Change MFC default setting of WindowMenuPopup if Cwm_SetWindowMenuPopup
- //is called by any MDI Child windows
- HMENU Cwm_MainBaseWnd::GetWindowMenuPopup(HMENU hMenuBar)
- {
- if(ms_hSetWindowMenuPopup)
- {
- HMENU hMenuReturn;
- hMenuReturn=ms_hSetWindowMenuPopup;
- ms_hSetWindowMenuPopup=NULL;
- return hMenuReturn;
- }
- if(m_hMenuDefault == hMenuBar)
- return ms_hSubMenu;
- return CMDIFrameWnd::GetWindowMenuPopup(hMenuBar);
- }
-
-
-
- BOOL Cwm_MainBaseWnd::OnCreateClient(LPCREATESTRUCT lpcs,
- CCreateContext* pContext)
- {
- BOOL bRetval;
- int ChildMenuPos;
- CMenu* pMenu = NULL;
- HMENU hMenu;
-
- ChildMenuPos = -2;
-
- hMenu = BLDGetMDISubMenu(GetMenu()->GetSafeHmenu(),ChildMenuPos);
- if(hMenu)
- {
- CMenu* pCMenu = CMenu::FromHandle(hMenu);
- bRetval = CreateClient(lpcs, pMenu);
- }
- else
- bRetval = CreateClient(lpcs, NULL);
- DWORD dwStyle=::GetWindowLong(m_hWndMDIClient,GWL_STYLE);
-
- if(dwStyle & MDIS_ALLCHILDSTYLES)
- {
- dwStyle -=MDIS_ALLCHILDSTYLES;
- ::SetWindowLong(m_hWndMDIClient,GWL_STYLE,dwStyle);
- }
-
-
- m_hMenuDefault = GetMenu()->GetSafeHmenu();
-
- return bRetval;
- }
-
-
-
- LRESULT Cwm_MainBaseWnd::SimHandlePrivateMessage(WPARAM wParam,LPARAM lParam)
- {
- LPBLDSetChildDialog lpSetChildDialog;
- switch(wParam)
- {
- case SIM_GETCHILDDIALOG:
- switch(LOWORD(lParam))
- {
- case 0: //Client area controls
- return (LRESULT)(LPSTR)(CSimClientDlg*)ms_pWndClient;
- case CBRS_RIGHT:
- return (LRESULT)(LPSTR)(CSimToolbar*)ms_pToolbarRight;
- case CBRS_LEFT:
- return (LRESULT)(LPSTR)(CSimToolbar*)ms_pToolbarLeft;
- case CBRS_BOTTOM:
- return (LRESULT)(LPSTR)(CSimToolbar*)ms_pToolbarBottom;
- case CBRS_TOP:
- return (LRESULT)(LPSTR)(CSimToolbar*)ms_pToolbarTop;
- }
- break;
- case SIM_SETCHILDDIALOG:
- lpSetChildDialog = (LPBLDSetChildDialog)lParam;
- switch(lpSetChildDialog->nStyle)
- {
- case 0: //Client area controls
- ms_pWndClient = (CSimClientDlg*)lpSetChildDialog->pWnd;
- break;
- case CBRS_RIGHT:
- ms_pToolbarRight = (CSimToolbar*)lpSetChildDialog->pWnd;
- break;
- case CBRS_LEFT:
- ms_pToolbarLeft = (CSimToolbar*)lpSetChildDialog->pWnd;
- break;
- case CBRS_BOTTOM:
- ms_pToolbarBottom = (CSimToolbar*)lpSetChildDialog->pWnd;
- break;
- case CBRS_TOP:
- ms_pToolbarTop = (CSimToolbar*)lpSetChildDialog->pWnd;
- break;
- }
- break;
- case SIM_RELOADACCELERATORS:
- BLDLoadAccelerators(this,IDR_SIMPLE);
- break;
- case SIM_LOADACCELTABLE:
- if(m_hAccelTable)
- m_hAccelTable=0;
- if(lParam)
- LoadAccelTable(MAKEINTRESOURCE((int)lParam));
- break;
- }
- return 0;
- }
-
-
- // *************************************************************
- // FUNCTION FOR SWITCHING MENU SET
- // *************************************************************
-
- BOOL BLDSwitchMenu(CWnd *pWnd,char *pTemplateName)
- {
- HMENU hMenu1,hMenu,hSubMenu;
- DWORD style;
-
- hMenu = 0;
- hSubMenu = 0;
-
- style = pWnd->GetStyle();
- if((style & WS_CHILD) == WS_CHILD) // Called from control in main window?
- {
- pWnd=pWnd->GetParent();
- if (!pWnd)
- return FALSE;
- style = pWnd->GetStyle();
- if((style & WS_CHILD) == WS_CHILD) // No menu in a WS_CHILD window.
- return FALSE;
- }
- if((style & WS_CAPTION) != WS_CAPTION) // No menu if no caption.
- return FALSE;
-
- hMenu1 = pWnd->GetMenu()->GetSafeHmenu();
-
- if (lstrcmpi(pTemplateName,"SIMPLE")==0)
- hMenu = BLDLoadMenu(pWnd,IDR_SIMPLE,&hSubMenu,TRUE);
-
- if (!hMenu)
- hMenu = LoadMenu(AfxGetResourceHandle(),pTemplateName);
- if (!hMenu)
- {
- BLDDisplayMessage(pWnd->GetSafeHwnd(),BLD_CannotLoadMenu,pTemplateName,
- MB_OK | MB_ICONASTERISK);
- return FALSE;
- }
-
- if(pWnd->GetSafeHwnd() != TheApp.m_pMainWnd->GetSafeHwnd())
- {
- if (!pWnd->SetMenu(CMenu::FromHandle(hMenu)))
- return FALSE;
- if (hMenu1)
- DestroyMenu(hMenu1);
- }
- else
- {
- Cwm_MainWnd *pCwm_MainWnd = (Cwm_MainWnd *)TheApp.m_pMainWnd;
- pCwm_MainWnd->MDISetMenu(CMenu::FromHandle(hMenu),CMenu::FromHandle(hSubMenu));
-
- if(pCwm_MainWnd->m_hMenuDefault)
- ::DestroyMenu(pCwm_MainWnd->m_hMenuDefault);
- pCwm_MainWnd->m_hMenuDefault=hMenu;
- pCwm_MainWnd->ms_hSubMenu =hSubMenu;
- }
-
- pWnd->DrawMenuBar();
- return TRUE;
- }
-
-
- // Code to load menu and add bitmaps
- HMENU BLDLoadMenu(CWnd *pWnd,int iResource,HMENU *phSubMenu,BOOL bLoad)
- {
- HMENU hMenu;
- int iMenuPos;
-
- *phSubMenu = 0;
- iMenuPos = -2;
- if (bLoad)
- hMenu = LoadMenu(AfxGetResourceHandle(),MAKEINTRESOURCE(iResource));
- else
- {
- if (!pWnd)
- return FALSE;
- hMenu = pWnd->GetMenu()->GetSafeHmenu();
- }
-
- if(!hMenu)
- return FALSE;
-
-
- if (pWnd)
- BLDLoadAccelerators(pWnd,iResource);
-
- *phSubMenu=BLDGetMDISubMenu(hMenu,iMenuPos);
- return hMenu;
- }
-
-
- // Code to load accelerators
- BOOL BLDLoadAccelerators(CWnd *pWnd,int iResource)
- {
-
- switch (iResource)
- {
- case IDR_SIMPLE:
- pWnd->SendMessage(wPrivateMessage,SIM_LOADACCELTABLE,(LONG)iResource);
- break;
- }
- return TRUE;
- }
-
-
- HMENU BLDGetMDISubMenu(HMENU hMenu,int iMenuPos)
- {
- HMENU hSubMenu;
- int i,iCount;
-
- if(!hMenu)
- return 0;
-
- hSubMenu = 0;
-
- switch(iMenuPos)
- {
- case -1: //No MDI Window Menu
- return 0;
- break;
- case -2: //Default MDI Window Menu
- break;
- default: //Specific MDI Window Menu
- hSubMenu=GetSubMenu(hMenu,iMenuPos);
- if(hSubMenu)
- return hSubMenu;
- break;
- }
-
- //Find default MDI Window Menu
- if(GetMenuItemCount(hMenu) > 0)
- {
- iCount = GetMenuItemCount(hMenu);
- if (iCount>=2)
- hSubMenu = GetSubMenu(hMenu,iCount-2);
- for(i=iCount-1; i>=0 && !hSubMenu; i--)
- hSubMenu=GetSubMenu(hMenu,i);
- }
- return hSubMenu;
- }
-